<layout name="page" />
<block name="content">
	{:widget('page_header/simple',array('name'=>'业务权限分配'))}

	<div class="operate-panel">
		<div class="split"></div>
		<a id="btn_save"  class="btn">保存</a>
	</div>
	<div class="row">
		<form id="form_data" method="post" action="">
			<div class="col-sm-4 sub-sidebar">
				<table class="table table-bordered">
					<thead>
						<tr>
							<th></th>
							<th>名称</th>
						</tr>
					</thead>
					<tbody>
						<volist name="role_list" id="data">
							<tr id="{$data.id}">
								<td class="col-4"><label class="inline pull-left">
									<input  type="checkbox" name="role_id[]" value="{$data.id}" />
								</label></td>
								<td>{$data.name}</td>
							</tr>
						</foreach>
					</tbody>
				</table>
			</div>
			<div class="col-sm-8 sub-content">

				<table class="table table-bordered">
					<thead>
						<tr>
							<th>&nbsp;</th>
							<th>编码</th>
							<th>名称</th>
							<th>备注</th>
						</tr>
					</thead>
					<tbody>
						<volist name="duty_list" id="data">
							<tr id="{$data.id}">
								<td class="col-4"><label >
									<input  type="checkbox" id="duty_{$data.id}" name="duty_list[]" value="{$data.id}"/>
								</label></td>
								<td class="col-10">{$data.duty_no}</td>
								<td class="col-10">{$data.name}</td>
								<td>{$data.remark}</td>
							</tr>
						</foreach>
					</tbody>
				</table>
			</div>
		</form>
	</div>
</block>
<block name="js">
	<script type="text/javascript">
		function test() {
			form_search.submit();
		};

		function save() {
			send_form("form_data", "{:url('set_duty')}");
		};

		function show_data(result) {
			$("input[name='duty_list[]']").each(function() {
				$(this).prop('checked', false);
			});
			for (var s in result.data) {
				$("#duty_" + result.data[s].duty_id).prop('checked', true);
			}
		}


		$(document).ready(function() {
			set_return_url(null);
			$(".sub-sidebar  tr").click(function() {
				$(".sub-sidebar  tr").attr("class", "");
				$(this).attr("class", "active");
				$("#role_id").val($(this).attr("id"));
				send_ajax("{:url('get_duty_list')}", "role_id=" + $(this).attr("id"), function(data) {
					show_data(data);
				});
			});
		});
	</script>
</block>